#pragma once
#if 0
#ifdef _WIN32
	#ifdef LOGAPI_EXPORTS
		#define LOGAPI_API __declspec(dllexport)
	#else
		#define LOGAPI_API __declspec(dllimport)
	#endif
#else
	#ifdef LOGAPI_EXPORTS
		#define LOGAPI_API __attribute__((visibility("default")))
	#else
		#define LOGAPI_API
	#endif
#endif
#endif
#define LOGAPI_API
#ifdef __cplusplus
extern "C"
{
#endif
	namespace cybertron {
		/**
		 * set the rate limit of writing log messages
		 *
		 * the limitation is to prevent the caller from writing too many log messages in a short period
		 *
		 *
		 * @param  rate_per_sec: the number of tokens to produce every second, one token will be consumed each time writing a log
		 * @param  burst_size: the maximum number of tokens to be kept if it was not consumed in the past
		 * @return	0: success
		 *			-1: fail
		 */
		LOGAPI_API int log_set_rate_limit(unsigned long long rate_per_sec, unsigned long long burst_size);

		/**
		 * enable network output
		 *
		 * if enabled, each log will be sent to the log server
		 *
		 *
		 * @param  ip: log server's ip address
		 * @param  port: log server's port
		 * @return	0: success
		 *			-1: fail
		 */
		LOGAPI_API int log_enable_net_appender(const char *ip, unsigned short port);

		/**
		 * enable console output
		 *
		 * if enabled, each log will be printed on the console
		 *
		 *
		 * @return	0: success
		 *			-1: fail
		 */
		LOGAPI_API int log_enable_console_appender();

		/**
		 * enable local file output
		 *
		 * if enabled, each log will be written to the local file
		 *
		 *
		 * @param  file_path: the full path of the log file
		 * @return	0: success
		 *			-1: fail
		 */
		LOGAPI_API int log_enable_file_appender(const char *file_path);

		/**
		 * log function
		 *
		 * five log functions of five different log levels
		 *
		 *
		 * @param  category: the log's category
		 * @param  producer: the log's producer, it should be the module name usually
		 * @param  fmt: the log's format
		 * @return void
		 */
		LOGAPI_API void log_debug(const char * category, const char *producer, const char *fmt, ...);
		LOGAPI_API void log_info(const char * category, const char *producer, const char *fmt, ...);
		LOGAPI_API void log_warn(const char * category, const char *producer, const char *fmt, ...);
		LOGAPI_API void log_error(const char * category, const char *producer, const char *fmt, ...);
		LOGAPI_API void log_fatal(const char * category, const char *producer, const char *fmt, ...);
	}
#ifdef __cplusplus
}
#endif